<extend name="Layout:form" />
<block name="title"><title>修改栏目</title></block>
<block name="subheader">
    <script language="javascript" type="text/javascript" src="{:asset('js/admin/content_add.js')}" charset="UTF-8"></script>
    <script type="text/javascript" src="{:asset('js/admin/attachupload.js')}"></script>
</block>
<block name="subnav">
    <a class="add fb" href="__MODULE__/Category/add?<?php echo $query_string; ?>"><em>添加栏目</em></a>　
    <a href="__MODULE__/Category/index?<?php echo $query_string; ?>"><em>栏目管理</em></a>
</block>
<block name="main">
    <form name="myform"  id="myform"  action="__MODULE__/Category/edit" method="post">
        <input type="hidden" name="id" value="<?php echo $term['id']; ?>">
        <table width="100%" class="table_form ">
            <tbody>
                <tr>
                    <th>栏目名称：</th>
                    <td>
                        <span id="normal_add">
                            <input type="text" name="info[catname]" id="catname" class="input-text" value="<?php echo $term['catname']; ?>">
                        </span>
                    </td>
                </tr>
                <tr id="catdir_tr">
                    <th>英文目录：</th>
                    <td><input type="text" name="info[catdir]" id="catdir" class="input-text" value="<?php echo $term['catdir']; ?>"></td>
                </tr>
                <tr>
                    <th width="100">上级栏目:</th>
                    <td>
                        <select name="info[parentid]" id="parentid">
                            <option value="0" <?php if($term['id'] == 0) echo "selected"; ?>>≡ 作为一级栏目 ≡</option>
                            <?php  foreach ($terms as $key => $value) { ?>
                            <option value="<?php echo $value['id'] ?>" <?php if($term['parentid'] == $value['id']) echo "selected"; ?>><?php echo cat_empty_deal($value, (isset($terms[$key+1]) ? $terms[$key+1]['parentid'] : 0),'parentid'); ?><?php echo $value['catname']; ?></option>
                            <?php } ?>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th width="100">缩略图：</th>
                    <td>
                        <?php echo \Org\Util\Form::image('thumb', $term['thumb'], ['upload_allowext' => 'jpg|png|gif|jpeg']); ?>
                    </td>
                </tr>
                <tr>
                    <th>描述：</th>
                    <td>
                        <textarea name="info[description]" maxlength="255" style="width:300px;height:60px;"><?php echo $term['description']; ?></textarea>
                    </td>
                </tr>

            </tbody>
        </table>
        <div class="bk15"></div>
        <input name="catid" type="hidden" value="">
        <input name="dosubmit" type="submit" value="提交" class="button">
    </form>
</block>
<block name="footer">

    <script type="text/javascript">
        $(function(){
            $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true}, function(){this.close();$(obj).focus();})}});

            $("#catname").formValidator({onshow:"请输入栏目名称",onfocus:"请输入栏目名称",oncorrect:"输入正确"}).inputValidator({min:1,onerror:"请输入栏目名称"}).defaultPassed();
            $("#catdir").formValidator({onshow:"请输入目录名称",onfocus:"通常使用小写，只能包含字母，数字和连字符（-）"}).regexValidator({regexp:"^([a-zA-Z0-9、-]|[_]){0,30}$",onerror:"目录名称必须为字母、数字、下划线、中划线"}).inputValidator({min:1,onerror:"请输入目录名称"}).ajaxValidator({type : "get",url : "__CONTROLLER__/public_check_catdir",data :"",datatype : "html",cached:false,getdata:{parentid:'parentid'},async:'false',success : function(data){ if( data == "1" ){return true;}else{return false;}},buttons: $("#dosubmit"),onerror : "目录名称已存在",onwait : "正在连接，请稍候。"}).defaultPassed();
        });
    </script>

</block>